package com.chenxi.util;

import com.google.common.collect.Maps;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 * 
 * @author Hu Xiaolong
 * @email 1hxl@163.com
 * @date 2017年12月12日 下午9:59:27
 */
public class ResultJson implements Serializable {
	private static final long serialVersionUID = 1L;

	private Integer code;

	private String msg;

	private Object data;


	public ResultJson() {
		this.code = 0;
		this.msg = "";
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public void error() {
		this.error("未知异常，请联系管理员");
	}

	public void error(String msg) {
		this.error(500,msg);
	}

	public void error(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	public void success() {
		this.success("操作成功");
	}

	public void success(String msg) {
		this.success(0,msg);
	}

	public void success(Integer code,String msg) {
		this.success(code,msg,null);
	}

	public  void success(Integer code,String msg,Object data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public static void main(String[] args){
		ResultJson r = new ResultJson();
		Map<String,Object> map = Maps.newHashMap();
		//map.put("ssss","sssss");
		//r.setData(map);
	}
}
